package com.stjb.furns.service.impl;

import com.stjb.furns.dao.MemberDAO;
import com.stjb.furns.dao.impl.MemberDaoImpl;
import com.stjb.furns.entity.Member;
import com.stjb.furns.service.MemberService;

/**
 * @Author: situ
 * @Date: 2025/5/25 22:07
 * @Description:
 **/
public class MemberServiceImpl implements MemberService {

    //定义一个MemberDAO属性
    private MemberDAO memberDAO = new MemberDaoImpl();

    @Override
    public boolean registerMember(Member member) {
        return memberDAO.saveMember(member) == 1 ? true : false;

    }

    /**
     * 判断用户名是否存在
     *
     * @param username 用户名
     * @return 如果用户名存在返回true
     */

    @Override
    public boolean isExistsUsername(String username) {

        return memberDAO.queryMemberByUsername(username) == null ? false : true;
    }

    /**
     * 判断是否登录成功
     *
     * @param username 用户名
     * @param password 密码
     * @return 可以登录返回true
     */
    @Override
    public Member login(String username, String password) {
        return memberDAO.queryMemberByUsernameAndPassword(username, password);
    }



}
